
object Inheritance{
   def main() : Unit = {
      println((new Test()).test());
   }
}

class Test{
   //var name : String;
   //var name : String;
   
   def test() : Int = {
      var cat : Animal;
      var dog : Animal;
      //var myVar : Int;
      //var fish : Fish; // Should not be ok...
      
      cat = new Cat();
      dog = new Dog();
      
      //fish = new Fish();

      if(cat.setName("Garfield") == "Garfield")
		  println("bob");
      if(dog.setName("Odie") == "Odie")
		  println("the sponge");

      println(dog.print());
      println(cat.print());
      return 0;
   }
}
/*
class A extends B {
}

class B extends C {
}

class C extends A {
  def getName() : String = {
    return name;
  }
}*/

class Animal {
   var name : String;

   def setName(n : String) : String = {
      return n;
   }

   def print() : String = {
      return (name + " says : " + this.makeNoise());
   }

   def makeNoise() : String = {
      return "noise";
   }
}

class Cat extends Animal{
   //var name : String;
 
   def eatMilk() : String = {
     return name;
   }
}

class Pussy extends Cat {
}

class Dog extends Animal{
   var Cat : Cat;
   def makeNoise() : String = {
      Cat = new Cat();
      return "baarrk";
   }
}

/*
class Fly extends Insect {
}*/
